package cn.edu.tju.se.auth.domain;

import java.util.List;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.OneToMany;

import org.hibernate.annotations.NotFound;
import org.hibernate.annotations.NotFoundAction;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import javax.persistence.JoinColumn;

//@Entity(name="Auth_Group")
@Entity(name="auth_group")
@JsonIgnoreProperties({ "handler","hibernateLazyInitializer" }) 
public class Group {
	@Id
	@GeneratedValue
	private Long id;

	private String name;

	private String type;
	
	private int rank;
//	@JsonIgnore
//	@ManyToMany(cascade = CascadeType.PERSIST, fetch = FetchType.LAZY)
//	@JoinTable(name = "Auth_r_User_Group", 
//	joinColumns = { @JoinColumn(name = "Group_ID", referencedColumnName = "id") }, 
//	inverseJoinColumns = { @JoinColumn(name = "User_ID", referencedColumnName = "id") })
//	@JoinTable(name = "auth_r_user_group_role", 
//	joinColumns = { @JoinColumn(name = "group_id", referencedColumnName = "id") }, 
//	inverseJoinColumns = { @JoinColumn(name = "user_id", referencedColumnName = "id") })
//	private Set<User> users;

//	@JsonIgnore
//	@ManyToMany(cascade = CascadeType.PERSIST, fetch = FetchType.LAZY)
//	@JoinTable(name = "Auth_r_Group_Role", 
//	joinColumns = { @JoinColumn(name = "Group_ID", referencedColumnName = "id") }, 
//	inverseJoinColumns = { @JoinColumn(name = "Role_ID", referencedColumnName = "id") })
//	@JoinTable(name = "auth_r_user_group_role", 
//	joinColumns = { @JoinColumn(name = "group_id", referencedColumnName = "id") }, 
//	inverseJoinColumns = { @JoinColumn(name = "role_id", referencedColumnName = "id") })
//	private Set<Role> roles;
	@JsonIgnore
	@OneToMany(cascade= {CascadeType.ALL},fetch = FetchType.LAZY)
	@JoinColumn(name = "group_id")
	private Set<Udr> myUdr;
	
	
	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	

	public Set<Udr> getMyUdr() {
		return myUdr;
	}

	public void setMyUdr(Set<Udr> myUdr) {
		this.myUdr = myUdr;
	}

	public String getType() {
		return type;
	}

	public void setType(String type) {
		this.type = type;
	}

	public int getRank() {
		return rank;
	}

	public void setRank(int rank) {
		this.rank = rank;
	}

}
